package ru.sazonov.ide.parser.processor

import ru.sazonov.ide.model.ModelPart
import ru.sazonov.ide.model.Unit

abstract class AbstractProcessor {

    def final ModelPart process(File f){
        if(!validate(f)) return null;

        Unit unit = new Unit(filename: f.absolutePath, name: f.name);
        ModelPart modelPart = new ModelPart(
                units: [unit]
        );

        parse(f, modelPart);

        return modelPart;
    }

    protected def abstract boolean validate(File f);
    protected def abstract void parse(File f, ModelPart mp);
}
